package com.cjl.eater.controller.v1;

import com.cjl.common.dtos.LoginDto;
import com.cjl.common.dtos.ResponseResult;
import com.cjl.eater.dtos.EaterLoginDto;
import com.cjl.eater.service.EaterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cjl
 * @version v1.0
 * @description TODO
 * @createTime 2023/2/7 17:01
 */
@Api(value = "EaterLoginController",description = "用户可以进行登录，注册和修改密码")
@RestController
@RequestMapping("/api/eater/login_auth")
public class EaterLoginController {
    @Autowired
    EaterService eaterService;

    /**
     * 登录或注册
     *
     * @return
     */
    @ApiOperation(value = "登录/注册",notes = "需要传递手机号，密码，以及status：0-注册，1-登录")
    @PostMapping("login")
    public ResponseResult login(@RequestBody LoginDto eaterLoginDto) {
        return eaterService.login(eaterLoginDto);
    }

    /**
     * 修改密码
     * @return
     */
    @ApiOperation(value = "修改密码",notes = "需要传递手机号，密码，以及status：2-修改密码")
    @PostMapping("modifyPassword")
    public ResponseResult modifyPassword(@RequestBody LoginDto eaterLoginDto){
        return eaterService.modifyPassword(eaterLoginDto);
    }
}
